home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-04-14 | 6.4 KB | 202 lines | [TEXT/KAHL] |
- The CArrangeList class implements a list much like that produced by
- Apple's List Manager. However, the list produced by this class can also
- be rearranged as user clicks the mouse. Rows are swapped and redrawn as
- the user drags on a row within the list. The CArrangeList class keeps
- track of all the rows and instead of flipping their data around in memory,
- it keeps a seperate list which acts as an index to the rows.
- This class is still in a ßeta version and still requires quite a bit of
- testing. I thought it would be best if other programmers could contribute
- ideas while this is being finished up. Any of your comments would be
- greatly appreciated.
-
- If you find this class useful, please send what you feel it's worth and
- any comments you have to -
-
- PATRICK DOANE
- 89 Fair Street
- Guilford CT, 06437
-
- I can also be reached on America Online.
-
- ScreenName - Patrick5
-
- Copyright © 1990, dba Imagination Creations.
- This class can be used in creating source code as long as you copyright
- your software. The source code may not be resold or used in a commercial
- product. The object code can be used in anyway you like.
-
- EXPLANATION OF INSTANCE VARIABLES
- =================================
-
- CPanorama *itsPanorama - The main drawing environment
- CScrollPane *itsScrollPane - The ScrollPane for itsPanorama
- short hIndent - The indent from the left edge of the row
- short vIndent - The indent up from the bottom edge of the row
- short rows - The number of rows in the ArrangeList
- short rowWidth - The width of each row
- short rowHeight - The height of each row
- short currentSelection - The currently selected row
- Boolean dirty - This tells if the ArrangeList has been rearranged
- long clickTime - The time of the last click (in 60ths of a second)
- short clickRow - The last row clicked in
- LongHandle itsOrder - A handle to the current order of the ArrangeList
- LongHandle itemOffsets - A handle to the offset table showing where each
- row starts within the itsItems handle
- Handle itsItems - A handle to the straight data used by the
- ArrangeList
- ShortFunc compareProc - A C Function that is called to compare two rows
- FORMAT short CompareProc(Ptr aPtr,Ptr bPtr,
- short aLen,short bLen)
- RETURNS -1 if aPtr is less than bPtr
- 0 if aPtr equals bPtr
- 1 if aPtr is greater than bPtr
- VoidFunc doubleProc - A C Function that is called after a double-click
- occurs
- FORMAT void DoubleProc(CArrangeList *theList)
-
- EXPLANATION OF INSTANCE METHODS
- ===============================
- void IArrangeList(CView *theEnclosure,CBureaucrat *theSupervisor,
- short theWidth,short theHeight,short theHEncl,
- short theVEncl,Boolean hasHoriz,Boolean hasVert,
- Boolean hasSizeBox,short theRows,short theRowWidth,
- short theRowHeight,ShortFunc theCompareProc,
- VoidFunc theDoubleProc);
-
- Initializes the ArrangeList. Variables are the same as what is passed
- for a Pane and a ScrollPange except for -
-
- theRowWidth,theRowHeight - the row's width and height;
- theCompareProc,theDoubleProc - Procedures to be called for
- comparing rows and for when a double click occurs
-
- NOTE - The Size Box is not currently used. It is there for later use.
-
- void Dispose(void);
-
- Disposes of the ArrangeList's handles,itsPanorama and itsScrollPane.
-
- void GetIndents(short *theHIndent,short *theVIndent);
-
- Gives the instance variables hIndent and vIndent.
-
- void GetRowCount(short *rowCount);
-
- Gives the instance variable rows.
-
- void GetRowDimensions(short *theWidth,short *theHeight);
-
- Gives the instance variables rowWidth and rowHeight.
-
- void GetSelection(short *theSelection);
-
- Gives the currentSelection.
-
- Boolean IsDirty(void);
-
- Returns true if the ArrangeList is dirty, false if not.
-
- void SetIndents(short theHIndent,short theVIndent,
- Boolean redraw);
-
- Sets the instance variables hIndent and vIndent and if redraw is true,
- will redraw the list.
-
- void SetRowDimensions(short theWidth,short theHeight,
- Boolean redraw);
-
- Sets the instance variables rowWidth and rowHeight and if redraw is true,
- will redraw the list.
-
- void SetSelection(short theSelection);
-
- Deselects currentSelection, sets the instance variable currentSelection,
- and the selects the currentSelection.
-
- void SetDirty(Boolean isDirty);
-
- Sets the instance variable dirty.
-
- void SetCompareProc(ShortFunc theFunc);
-
- Sets the instance variable compareProc.
-
- void SetDoubleProc(VoidFunc theFunc);
-
- Sets the instance variable doubleProc.
-
- void AddRow(short count,short rowNum,Boolean redraw);
-
- Adds count rows after row rowNum, and if redraw is true, redraws the
- list.
-
- NOTE - AddRow has never been tested with adding rows that are not at
- the end of the list. If this doesn't work please inform me and
- I will fix it right away.
-
- void DeleteRow(short count,short rowNum,Boolean redraw);
-
- Deletes count rows at row rowNum, and if redraw is true, redraws the
- list.
-
- void SetRow(Ptr dataPtr,long dataLen,short rowNum,
- Boolean redraw);
-
- Sets the row rowNum's data to dataPtr for dataLen bytes. If redraw is
- true, it redraws the list.
-
- void DrawRow(register short rowNum);
-
- Draws row rowNum.
-
- void InvertRow(register short rowNum);
-
- Inverts row rowNum;
-
- Boolean ValidRow(register short rowNum);
-
- Test whether or not, rowNum is a valid row within the list.
-
- void Draw(void);
-
- Draws the entire list.
-
- void DoClick(Point hitPt,short modifierKeys,long when);
-
- Called when the user clicks in the ArrangeList.
-
- Ptr GetRowOffset(register short rowNum);
-
- Returns a Ptr to the offset where row rowNum is stored.
-
- long GetRowSize(register short rowNum);
-
- Returns the size of row rowNum.
-
- void Sort(short left,short right);
-
- Sorts the ArrangeList by calling QuickSort.
-
- Boolean Search(register Ptr dataPtr,register short dataLen,
- short *theRow)
-
- Searches the list until it finds a row that is greater than or equal
- to dataPtr.
-
-
- EXPLANATION OF OTHER OBJECTS USED BY ARRANGELIST
- ================================================
-
- CListPanorama - the Draw and DoClick procedures merely call the ArrangeList
- procedures by the same name.
-
- CArrangeTask - Called when the user clicks in the ArrangeList. Performs
- all rearranging and checks for double clicks.
-
-
- EXPLANATION OF OTHER PROCEDURES USED BY ARRANGELIST
- ===================================================
-
- QuickSort - Sorts the ArrangeList.
- CompareItems - Default routine for comparing rows.
- DoubleClick - Default routine for double clicking (does nothing)